-
Notifications
You must be signed in to change notification settings - Fork 217
Add function to compute statistics about a scheduled product #6589
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
7f78922
to
d63ea02
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6589 +/- ##
==========================================
- Coverage 99.11% 99.10% -0.02%
==========================================
Files 399 399
Lines 40717 40723 +6
==========================================
+ Hits 40358 40359 +1
- Misses 359 364 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Have you considered to provide the information from this function in an amqp message so that external tooling can react on such "build is done"? |
I think emitting an amqp message would make this more challenging in two ways:
We should probably only solve the problem at hand for now and in the simplest way. Point 1 let me think of an even simpler approach than a hook script: Instead of running a hook script on the OSD host we could also just provide an API endpoint that returns these statistics. Then some bot can query this route once per hour (probably once every 6 hours would be enough) for relevant scheduled products if there is a pending "increment" to be approved. This would be efficient and easy to implement because:
This approach still has one challenge, though. To find the most recent relevant scheduled product for each arch we need a query like this:
This is currently not very efficient because we don't have an index on the scheduled products table but it has almost 3 million rows. (The query seems to be still fast enough for now and we only have to do it e.g. once per hour.) I think actually all approaches have this challenge because we always have to determine whether the scheduled product we are currently dealing with (e.g. in its hook script or when receiving an amqp event about it) is still the most recent. With the API approach we would at least never have to invoke this query just to find out that the scheduled product we are currently dealing with is not relevant anymore. (And by the way, just when I'm writing about this I find that this is really not a fictional aspect to care about as Richard has just re-triggered the scheduled product, see https://suse.slack.com/archives/C08DC2SHABV/p1752637433485059?thread_ts=1750847709.352269&cid=C08DC2SHABV.) Note that if we have an API as I mentioned we can still think of emitting an amqp message in addition and for specific products. (In addition as per point 1 and only for specific scheduled products to avoid point 2.) |
This is to be able to add hook script support for scheduled products because for this we need to be able to determine whether all jobs of a scheduled product are done (to execute the hook script in this case). The hook script is supposed to do automatic approval/disapproval of changes. Hence it needs not only to know whether all jobs are done but also the state/result they ended up with. So this function returns these kinds of statistics instead of a binary "all done". Maybe it will need to be changed to return more high level statistics (like "all passed"), though. Related ticket: https://progress.opensuse.org/issues/184690
d63ea02
to
76b7951
Compare
This is to be able to add hook script support for scheduled products because for this we need to be able to determine whether all jobs of a scheduled product are done (to execute the hook script in this case).
The hook script is supposed to do automatic approval/disapproval of changes. Hence it needs not only to know whether all jobs are done but also the state/result they ended up with. So this function returns these kinds of statistics instead of a binary "all done". Maybe it will need to be changed to return more high level statistics (like "all passed"), though.
Related ticket: https://progress.opensuse.org/issues/184690
Just a draft because it still needs tests and it also makes no sense to merge this without being used. However, I tested this on OSD with production data and scheduled products that have many jobs (up to 260) and a few restart chains (of depth up to 6) and it was very fast.
That's good because it means the hardest part of this feature is solved. Now I just need to use this in the Minion job where we already execute job done hooks to check whether we can execute a scheduled product hook and execute that hook in the same way we execute job done hooks. I would read the script name/path from the scheduled product settings. I would pass the scheduled product ID as first argument and the statistics as JSON as second argument. (As mentioned in the commit message statistics could be a bit more high-level than what I currently have.)
Then I can write the hook script. I think this could be done in Python to be able to use the osc Python libraries directly - just like qem-bot does. Or a simple shell script that invokes the
osc
CLI tool.So I guess that would be the plan for this feature and it is maybe useful in the future for more than just the increment approval.